/**
 * ---------------------------
 * Time: 2017/8/6 16:07.
 * Author: Cangshi
 * View: http://palerock.cn
 * ---------------------------
 */
define([
    'app', 'dexie'
], function (app, Dexie) {
    var INDEXED_DB = app.CONFIG.DATA_SOURCES.INDEXED_DB;
    app.provider(INDEXED_DB._NAME, function () {
        // 配置初始化数据库
        var dexieDB = INDEXED_DB.dexieDB = new Dexie('test_data_2');
        dexieDB.version(1).stores({
            configs: 'key, value',
            devices: 'deviceNo, deviceName, deviceDiscription, runningDuration, daysNumber, registerInfo, runningRecords, repairRecords, maintainPlans',
            maintainTemplate: '++templateId, templateName, templateDiscription, maintainPlans'
        });
        dexieDB.version(2).stores({
            safetyAccident: '++accidentId, accidentDescription, accidentDetail, accidentAddTime, accidentHappenedTime, accidentCostMoney'
        });
        dexieDB.version(3).stores({
            safetyAccident: '++accidentId, accidentDescription, accidentDetail, accidentAddTime, accidentHappenedTime, accidentCostMoney, accidentLevel'
        });
        dexieDB.version(4).stores({
            devices: 'deviceNo, deviceName, deviceDiscription, runningDuration, daysNumber, registerInfo, runningRecords, repairRecords, maintainPlans, memorandum'
        });
        this.$get = function () {
            return INDEXED_DB
        };
    });
});
